@extends('admin::layouts.master')
@section('title')
    系统消息列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" id="form1">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 200px;">
                                <input type="text" name="nickname" placeholder="用户名" value="{{$arr_search['nickname']}}" autocomplete="off" class="layui-input"></div>
                                <input type="hidden" name="user_id" value="{{$arr_search['user_id']}}">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 200px;">
                                <input type="text" name="name" placeholder="门店名称" value="{{$arr_search['name']}}" autocomplete="off" class="layui-input"></div>
                                <input type="hidden" name="shop_id" value="{{$arr_search['shop_id']}}">

                            <div class="layui-input-inline" style="width: 200px;">
                                <select name="pid">
                                    <option value="">消息类型</option>
                                    <option value="1" @if( $arr_search['pid'] == 1 ) selected="" @endif >系统消息</option>
                                    <option value="2" @if( $arr_search['pid'] == 2 ) selected="" @endif >活动消息</option>
                                    <option value="3" @if( $arr_search['pid'] == 3 ) selected="" @endif >订单消息</option>
                                </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>标题</th>
                                <th>图片</th>
                                <th>内容</th>
                                <th>类型</th>
                                <th>是否阅读</th>
                                <th>用户名</th>
                                <th>门店名称</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                                <tr>
                                    <td>{{ $value['id'] }}</td>
                                    <td>{{ $value['title'] }}</td>
                                    <td><img src="{{ $value['img']['full_src'] }}"> </td>
                                    <td>{{ $value['content'] }}</td>
                                    <td>{{ $value['pid']['name'] }} - {{ $value['type']['name'] }}</td>
                                    <td>{{ $value['is_read']['name'] }}</td>
                                    <td> <a href="#" data-id="{{$value['user_id']}}" title="查看他的记录" class="click_a"> {{ $value['user']['nickname'] }} </a> </td>
                                    <td> <a href="#" data-id="{{$value['shop_id']}}" title="查看他的记录" class="click_b"> {{ $value['shop']['name'] }} </a> </td>
                                </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            $("body").on('click','#fdsfs',function(){
                var id = $(this).attr('data-id');
                layer.prompt({title: '请填写处理结果信息', formType: 2}, function(content, index){
                    $.ajax({
                        url: js_url('admin-feedback-update-remark'),
                        type: 'post',
                        data: {id:id,remark:content,'_token': '{{csrf_token()}}'},
                        dataType: "json",
                        success: function (result) {
                            if (result.state === 0) {
                                layer.msg(result.msg, {time: 1000, icon: 1}, function () {
                                    window.location.reload()//刷新父页面
                                });
                            } else {
                                layer.msg(result.msg, {time: 2000, icon: 5});
                            }
                        }
                    });
                });
            });


            $(".click_a").click(function(){
                var user_id = $(this).attr('data-id');
                $("input[name='user_id']").val( user_id );
                $("input[name='nickname']").val( $(this).text() );
                $("#form1").submit();
            })

            $(".click_b").click(function(){
                var shop_id = $(this).attr('data-id');
                $("input[name='shop_id']").val( shop_id );
                $("input[name='name']").val( $(this).text() );
                $("#form1").submit();
            })

        })
    </script>
@endsection




